<?php
/**
 * Created by PhpStorm.
 * User: User
 * Date: 2017/9/29
 * Time: 8:16
 */
class person{
    private $name;
    private $age;
    private $sex;


    public function __construct($n,$a,$s)
    {
        $this->name=$n;
        $this->age=$a;
        $this->say=$s;
    }


    public function say(){
        echo "我的名字是:{$this->name} ,我的性别是:{$this->sex} ,我的年龄是{$this->age} ";
    }


    public function __set($name, $value)
    {
        if ($name=='age'){
            $this->age=(($value<0)?1:$value);
        }
        $this->name=$value;
    }
}

$my=new person('缪开始','男',20);
$my->say();
$my->age=-40;
$my->say();